package com.platform.enums.converters;

import com.platform.enums.CommFlagType;

import javax.persistence.AttributeConverter;
import javax.persistence.Converter;

/**
 * @author coder
 */
@Converter
public class CommFlagTypeConverter implements AttributeConverter<CommFlagType, String> {

    @Override
    public String convertToDatabaseColumn(CommFlagType attribute) {
        return attribute==null?null:attribute.getFvalue();
    }

    @Override
    public CommFlagType convertToEntityAttribute(String dbData) {
        return CommFlagType.getFlagByValue(dbData);
    }
}
